package yja.gzw.app.window

import android.util.Log
import android.view.View
import android.view.ViewGroup
import yja.gzw.app.model.UserData

class Chicun {

    var xmlw:Float=822f
    var xmlh:Float=1462f

    val w:Float= UserData.kuan.toFloat()/xmlw
    val h:Float= UserData.gao.toFloat()/xmlh

    fun chicun(view: View, with:Int, hitght:Int){

        val layoutParams = view.layoutParams
        layoutParams.width = (with*2*w).toInt()// 例如，设置宽度为 200 像素
        layoutParams.height = (hitght*2*w).toInt() // 例如，设置高度为 200 像素
        Log.e("实际尺寸",  ""+layoutParams.width+"w为"+w)
        view.layoutParams = layoutParams
    }
    fun chicunwai(view:View,left:Int,top:Int,right:Int,bottom:Int){

        val layoutParams = view.layoutParams as ViewGroup.MarginLayoutParams

// 设置外边距
        layoutParams.setMargins((left*2*w).toInt(), (top*2*w).toInt(), (right*2*w).toInt(), (bottom*2*w).toInt())

// 应用修改后的 LayoutParams
        view.layoutParams = layoutParams


    }

}